const express = require('express');
const expressJoi = require('@escook/express-joi');

const router = express.Router();

const {
  getArticleCates,
  addArticleCate,
  deleteCateById,
  getCateById,
  updateCateById,
} = require('../router_handler/artcate');

const {
  add_art_cate,
  delete_cate_schema,
  get_cate_schema,
  update_cate_schema,
} = require('../schema/artcate');

// 获取所有文章分类数据
router.get('/cate', getArticleCates);

// 添加文章分类
router.post('/addcates', expressJoi(add_art_cate), addArticleCate);

// 删除文章分类
router.get('/deletecate/:id', expressJoi(delete_cate_schema), deleteCateById);

// 通过id获取文章分类列表数据
router.get('/cate/:id', expressJoi(get_cate_schema), getCateById);

router.post('/updatecate', expressJoi(update_cate_schema), updateCateById);

module.exports = router;
